using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;
using Pay.Core;

namespace Pay.Service.AutoMapper {
	public class RefundOrderMapper : IStartupDto {
		private IMapperConfigurationExpression _cfg;
		public RefundOrderMapper(IMapperConfigurationExpression cfg) {
			_cfg = cfg;
		}
		public void Execute() {
			Create();
		}
		protected virtual void Create() {
			//_cfg.CreateMap<refund_order_dto, RefundOrder>()
			//	.ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
			//	.ForMember(dest => dest.OrderNo, src => src.MapFrom(c => c.order_no))
			//	.ForMember(dest => dest.OrderId, src => src.MapFrom(c => c.order_id))
			//	.ForMember(dest => dest.TradeNo, src => src.MapFrom(c => c.trade_no))
			//	.ForMember(dest => dest.Amount, src => src.MapFrom(c => c.amount))
			//	.ForMember(dest => dest.ApplyTime, src => src.MapFrom(c => c.apply_time.ToUnix()))
			//	.ForMember(dest => dest.Reason, src => src.MapFrom(c => c.reason))
			//	.ForMember(dest => dest.Status, src => src.MapFrom(c => c.status))
			//	.ForMember(dest => dest.AuditTime, src => src.MapFrom(c => c.audit_time.ToUnix()))
			//	.ForMember(dest => dest.PayId, src => src.MapFrom(c => c.pay_id))
			//	.ForMember(dest => dest.RefundTime, src => src.MapFrom(c => c.refund_time.ToUnix()));
			_cfg.CreateMap<RefundOrder, refund_order_dto>()
				.ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
				.ForMember(dest => dest.order_no, src => src.MapFrom(c => c.OrderNo))
				.ForMember(dest => dest.order_id, src => src.MapFrom(c => c.OrderId))
				.ForMember(dest => dest.amount, src => src.MapFrom(c => c.Amount))
				.ForMember(dest => dest.apply_time, src => src.MapFrom(c => c.ApplyTime.ToDateTime()))
				.ForMember(dest => dest.status, src => src.MapFrom(c => c.Status))
				.ForMember(dest => dest.pay_id, src => src.MapFrom(c => c.PayId))
				.ForMember(dest => dest.refund_time, src => src.MapFrom(c => c.RefundTime.ToDateTime()))
				.ForMember(dest => dest.pay_info, src => src.MapFrom(c => c.PayInfo));
		}
	}
}
